package com.xbts.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xbts.system.mapper.CnGovernmentCloudTypeMapper;
import com.xbts.system.domain.CnGovernmentCloudType;
import com.xbts.system.service.ICnGovernmentCloudTypeService;
import com.xbts.common.utils.DateUtils;
import com.xbts.common.utils.SecurityUtils;

/**
 * 政务云服务器类型Service业务层处理
 * 
 * @author xbts
 * @date 2023-08-23
 */
@Service
public class CnGovernmentCloudTypeServiceImpl  extends ServiceImpl<CnGovernmentCloudTypeMapper, CnGovernmentCloudType> implements ICnGovernmentCloudTypeService {

    /**
     * 查询政务云服务器类型列表
     *
     * @param cnGovernmentCloudType 政务云服务器类型
     * @return 政务云服务器类型
     */
    @Override
    public List<CnGovernmentCloudType> selectCnGovernmentCloudTypeList(CnGovernmentCloudType cnGovernmentCloudType) {
        LambdaQueryWrapper<CnGovernmentCloudType> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CnGovernmentCloudType::getDeleteFlag, "0");
        return list(queryWrapper);
    }

    /**
     * 查询政务云服务器类型
     *
     * @param id 政务云服务器类型主键
     * @return 政务云服务器类型
     */
    @Override
    public CnGovernmentCloudType selectCnGovernmentCloudTypeById(String id) {
        return getById(id);
    }

    /**
     * 新增政务云服务器类型
     *
     * @param cnGovernmentCloudType 政务云服务器类型
     * @return 结果
     */
    @Override
    public boolean insertCnGovernmentCloudType(CnGovernmentCloudType cnGovernmentCloudType) {
        cnGovernmentCloudType.setCreateBy(SecurityUtils.getUserId().toString());
        return save(cnGovernmentCloudType);
    }

    /**
     * 修改政务云服务器类型
     *
     * @param cnGovernmentCloudType 政务云服务器类型
     * @return 结果
     */
    @Override
    public boolean updateCnGovernmentCloudType(CnGovernmentCloudType cnGovernmentCloudType) {
        cnGovernmentCloudType.setUpdateBy(SecurityUtils.getUserId().toString());
        cnGovernmentCloudType.setUpdateTime(DateUtils.getNowDate());
        return updateById(cnGovernmentCloudType);
    }

    /**
     * 批量删除政务云服务器类型
     *
     * @param ids 需要删除的政务云服务器类型主键
     * @return 结果
     */
    @Override
    public boolean deleteCnGovernmentCloudTypeByIds(List<String> ids) {
        LambdaUpdateWrapper<CnGovernmentCloudType> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.in(CnGovernmentCloudType::getServerTypeId, ids);
        updateWrapper.set(CnGovernmentCloudType::getDeleteFlag, "1");
        return update(updateWrapper);
    }

    /**
     * 删除政务云服务器类型信息
     *
     * @param id 政务云服务器类型主键
     * @return 结果
     */
    @Transactional
    @Override
    public boolean deleteCnGovernmentCloudTypeById(String id) {
      return removeById(id);
    }

}
